﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using SPUtility;

namespace ILX.SP.WebApp
{
    public partial class taskapproval : UserControl
    {
        int curID = default(int);
        int ItemID
        {
            get
            {
                int.TryParse(Request.QueryString["ID"].ToString(), out curID);
                return curID;
            }
            set
            {
                curID = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMessage.Text = SPUtility.WebConstantsResource.SuccessMessage;


            if (!Page.IsPostBack)
            {
                ddlTaskStatus.Items.Add(new ListItem("Approve", "1"));
                ddlTaskStatus.Items.Add(new ListItem("Reject", "2"));
              //  ddlTaskStatus.Items.Add(new ListItem("Hold", "3"));

            }
        }

        protected void SaveChanges_Click(object sender, EventArgs e)
        {
            WorkflowHelper wfHelper = new WorkflowHelper();
            wfHelper.ApproveRejectWFTask(ItemID,ddlTaskStatus.SelectedItem.Value == "1");
            
            // wfHelper.ApproveWFProcess();
            // txtComment.Text

            closeModalDialog();

        }


        private void closeModalDialog()
        {
            string script = "parent.closeModalDialog();";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"CLOSE_SCRIPT", script, true);
        }
    }
}
